//package com.utils.spring.config;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
//import com.fasterxml.jackson.annotation.PropertyAccessor;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import lombok.extern.slf4j.Slf4j;
//
//@Slf4j
//@Configuration
//@ComponentScan("com.kyhd.bidder.redis")
//public class RedisConfiguration {
//	
//	@Value("${redis.ip}")
//    private String redis_ip;
//	
//	@Value("${redis.port}")
//    private int redis_port;
//	
//	int timeout = 20000;
//	
//	@Bean
//	JedisConnectionFactory jedisConnectionFactory() {
//	    JedisConnectionFactory jedisConFactory = new JedisConnectionFactory();
//	    jedisConFactory.setHostName(redis_ip);
//	    jedisConFactory.setPort(redis_port);
//	    jedisConFactory.setTimeout(timeout);
//	    log.info("redis ip:{} port:{}",redis_ip,redis_port);
//	    jedisConFactory.setDatabase(7);
//	    return jedisConFactory;
//	}
//	
//	
//	@Bean(name="redisTemplate")
//	public RedisTemplate<String, Object> redisTemplate() {
////	    RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
////	    template.setConnectionFactory(jedisConnectionFactory());
////	    template.setKeySerializer(new StringRedisSerializer());
////	    template.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));
////	    template.afterPropertiesSet();
//	    //设置序列化
//        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
//        ObjectMapper om = new ObjectMapper();
//        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
//        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
//        jackson2JsonRedisSerializer.setObjectMapper(om);
//        // 配置redisTemplate
//        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
//        redisTemplate.setConnectionFactory(jedisConnectionFactory());
//        redisTemplate.setKeySerializer(new StringRedisSerializer()); // key序列化
////        redisTemplate.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));
//        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); // value序列化
//        redisTemplate.setHashKeySerializer(new StringRedisSerializer()); // Hash key序列化
//        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); // Hash value序列化
//        redisTemplate.afterPropertiesSet();
//	    return redisTemplate;
//	}
//}
